package tichu_project252.View.Buttons;

import java.awt.Image;
import java.awt.Toolkit;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import tichu_project252.Controller.exitHandler;
import tichu_project252.Model.Model;

/**
 * This class implements the event handler of exit button.
 *
 * This action listener is implemented to define what should be done when a user
 * push the exit button.
 *
 * @see <a
 * href="http://docs.oracle.com/javase/tutorial/uiswing/events/actionlistener.html">actionListener</a>
 *
 * @author Alexandra Barka, ΑΜ: 2867, login : barka.
 * @version %I%, %G%
 */
public class ExitButton extends JButton {

    /**
     *
     * Constructs an Exit button.
     *
     * <p><b>Constructor: </b>ExitButton(Model m) </p>
     *
     * <p><b>Precondition: </b> </p> <p><b>Postcondition: </b> Constructs a new
     * JButton </p>
     *
     * @param m The model
     *
     */
    public ExitButton(Model m) {
        super();

            Image img = Toolkit.getDefaultToolkit().createImage(this.getClass().getResource("/tichu_project252/Images/x.png"));
            System.out.println(img.toString());
            this.setIcon(new ImageIcon(img));
System.out.println(img.toString());
        this.addActionListener(new exitHandler(m));
    }
}
